<template>
	<div class="systemManage">
		<a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol">
			<!-- <a-form-model-item label="可用币种">
				<a-radio-group v-model="form.type">
					<a-radio :value="1">USTD</a-radio>
					<a-radio :value="2">FIL</a-radio>
				</a-radio-group>
			</a-form-model-item> -->
			<!-- <a-form-model-item label="客户出金设置">
				<a-select v-model="form.region">
					<a-select-option value="100U">
						最小出金量
					</a-select-option>
					<a-select-option value="5FIL">
						最小提币量
					</a-select-option>
					<a-select-option value="20%">
						出金手续费
					</a-select-option>
					<a-select-option value="1000U">
						提现免审核限额
					</a-select-option>
				</a-select>
			</a-form-model-item> -->
			<a-form-model-item label="出矿时间设置">
				<a-time-picker style="width: 168px;" v-model="form.time1" :default-value="moment('01:00:00', 'HH:mm:ss')" format="HH:mm:ss" />
			</a-form-model-item>
			<a-form-model-item label="单T产币效率调整参数">
				<a-input style="width: 168px;" v-model="form.delivery" suffix="(%)"/>
			</a-form-model-item>
			<a-form-model-item label="结算时间设置">
				<a-time-picker style="width: 168px;" v-model="form.time2" :default-value="moment('16:00:00', 'HH:mm:ss')" format="HH:mm:ss" />
			</a-form-model-item>
			<!-- <a-form-model-item label="FIL汇率">
				<a-radio-group v-model="form.resource">
					<a-radio value="0.95">采用外部价</a-radio>
					<a-radio value="150.23">采用固定价</a-radio>
				</a-radio-group>
			</a-form-model-item> -->
			<!-- <a-form-model-item label="算力券">
				<a-input style="width: 130px;" v-model="form.desc" />
			</a-form-model-item> -->
			<a-form-model-item label="选择出矿日期">
				<a-date-picker style="margin-right: 20px;" v-model="form.date" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD" />
        <a-button type="primary" @click="outStorehouse" :disabled="disabled">
					人工出矿
				</a-button>
				<a-button type="primary" style="margin-left: 10px;" @click="settlement">
					人工结算
				</a-button>
			</a-form-model-item>
		</a-form-model>
	</div>
</template>

<script>
	import moment from 'moment'
	import {
		distribute,
		dispenseIssue
	} from '../../serves/index.js'
	export default {
		data() {
			return {
				labelCol: {
					span: 4
				},
				wrapperCol: {
					span: 10
				},
				form: {
					name: '',
					region: undefined,
					date: '',
					time1: '',
					time2: '',
					delivery: '100',
					type: [],
					resource: '',
					desc: ''
				},
				disabled: false
			};
		},
		methods: {
      moment,
			// 出仓
			outStorehouse() {
        if (!this.form.date) {
          this.$message.error('请选择出矿日期！');
          return
        }
				let params = {
					data: this.form.date
				}
				this.disabled = true
				dispenseIssue(params).then(res => {
					if (res.status == 200 && res.data.status.code == 200) {
						this.$message.success('出矿成功！')
					} else {
            this.$message.error('出矿失败！请联系管理员！')
            this.disabled = false
          }
				})
			},
			// 结算
			settlement() {
        if (!this.form.date) {
          this.$message.error('请选择结算日期！');
          return
        }
				let params = {
					data: this.form.date
				}
				distribute(params).then(res => {
					if (res.status == 200 && res.data.status.code == 200) {
						this.$message.success('结算成功！')
						this.disabled = false
					} else {
            this.$message.error('结算失败！请联系管理员！')
          }
				})
			}
		}
	};
</script>

<style lang="scss">
	.systemManage {

		.ant-table-thead>tr>th,
		.ant-table-tbody>tr>td {
			padding: 10px;
		}

		.ant-form-item-control {
			text-align: left !important;
		}
	}
</style>
